(function() {
	/**********订单更多弹出层 S**********/
	$(".order_more").on("click", function(e) {
		$(".order_inf_window").fadeIn();

		$(document).one("click", function() {
			$(".order_inf_window").fadeOut();
		});

		e.stopPropagation();
	});

	$(".order_more").on("click", function(e) {
		e.stopPropagation();
	});
	/***********订单更多弹出层 E*********/
	/**********订单弹出层一 S**********/
	$(".order_o_mid_con li:nth-child(4) span").on("click", function() {
		$("#shanchu1").fadeIn();
	})
	$(".o4_cof").on("click", function() {
		$("#shanchu1").fadeIn();
	})
	$("#wodzz2_mask_dele").on("click", function() {
			$("#shanchu1").fadeOut();
		})
		/***********订单弹出层一 E*********/

	/**********订单弹出层二 S**********/
	$(".o2_ok").on("click", function() {
		$("#shanchu1").fadeOut();
		o8_change(1);
		$("#shanchuchenggong").text(o8_str1);
		$("#shanchu2").fadeIn();
	});
	$(".o2_no").on("click", function() {
		$("#shanchu1").fadeOut();
		o8_change(1);
		$("#shanchuchenggong").text(o8_str2);
		$("#shanchu2").fadeIn();
	});
	$(".o4_ok").on("click", function() {
		$("#shanchu1").fadeOut();
		o8_change(2);
		$("#shanchuchenggong").text(o8_str1);
		$("#shanchu2").fadeIn();
	});
	$(".o4_no").on("click", function() {
		$("#shanchu1").fadeOut();
		o8_change(2);
		$("#shanchuchenggong").text(o8_str2);
		$("#shanchu2").fadeIn();
	});
	/*****根据弹窗选择对应的语句*******/
	var o8_str1, o8_str2;

	function o8_change(o8_S) {
		switch(o8_S / 1) {
			case 1:
				o8_str1 = "取消成功";
				o8_str2 = "取消失败";
				break;
			case 2:
				o8_str1 = "收货成功";
				o8_str2 = "收货失败";
				break;
			case 3:
				o8_str1 = "删除成功";
				o8_str2 = "删除失败";
				break;
			default:
				break;
		}
	}
	$("#chacha").on("click", function() {
			$("#shanchu2").fadeOut();
		})
		/**********订单弹出层二 E**********/
		/*************动态改变状态的距离 S*******************/
	function hebing() {
		var argument = arguments;
		for(var i = 0; i < argument.length; i++) {
			var argument_index = argument[i];
			console.log($('div[data-name=' + argument_index + '] .colsbor tr:nth-child(2) td:nth-child(4)'));
			$('div[data-name=' + argument_index + '] .colsbor tr:nth-child(2) td:nth-child(4)').attr("rowspan", $('div[data-name=' + argument_index + '] .colsbor .ptb_xs').length);
			$('div[data-name=' + argument_index + '] .colsbor .ptb_xs:not(:first-of-type :nth-of-type(2)) td:nth-child(4)').css("display", "none");
			$('div[data-name=' + argument_index + '] .colsbor tr:nth-child(2) td:nth-child(5)').attr("rowspan", $('div[data-name=' + argument_index + '] .colsbor .ptb_xs').length);
			$('div[data-name=' + argument_index + '] .colsbor .ptb_xs:not(:first-of-type :nth-of-type(2)) td:nth-child(5)').css("display", "none");
			$('div[data-name=' + argument_index + '] .colsbor tr:nth-child(2) td:nth-child(6)').attr("rowspan", $('div[data-name=' + argument_index + '] .colsbor .ptb_xs').length);
			$('div[data-name=' + argument_index + '] .colsbor .ptb_xs:not(:first-of-type :nth-of-type(2)) td:nth-child(6)').css("display", "none");
		}
	}
	hebing("not_pay", "deliver_goods", "evaluate", "take_goods", "jiaoyichenggong", "jiaoyiguanbi");

	/*鼠标放到留上面显现弹窗*/
	// $(".stay").each(function() {
	// 	$(this).on("mouseover", function() {
	// 		var tds = $(this).parent().parent().parent().find(".ptb_xs").length;
	// 		// console.log(tds);
	// 		$(this).parent().find(".dialog:first-of-type").css({
	// 			"display": "block",
	// 			"bottom": 95 + 77 * (tds - 1) + "px"
	// 		});
	// 	})
	// 	$(this).parent().on("mouseleave", function() {
	// 		$(this).parent().find(".dialog:first-of-type").css({
	// 			"display": "none",
	// 		});
	// 	})
	// })

	/**********交易状态***********/

	$(".jiaoyi").on("mouseover", function() {
		$(".jiaoyi i").css("transform", "rotate(180deg)");
		$(".trade").css("display", "block");
		$(".jiaoyi").css({
			"background": "#878787"
		})
		$(".jiaoyi span").css("color", "#fff");
		$(".jiaoyi i").css("color", "#fff");
		$(".trade").on("mouseover", function() {
			$(".jiaoyi i").css("transform", "rotate(180deg)");
			$(".trade").css("display", "block");
			$(".jiaoyi").css({
				"background": "#878787"
			})
			$(".jiaoyi span").css("color", "#fff");
			$(".jiaoyi i").css("color", "#fff");
		})
		$(".trade").on("mouseleave", function() {
			$(".jiaoyi i").css("transform", "rotate(0deg)");
			$(".trade").css("display", "none");
			$(".jiaoyi").css({
				"color": "#99999A",
				"background": "#f8f8f8"
			})
			$(".jiaoyi span").css("color", "#99999A");
			$(".jiaoyi i").css("color", "#99999A");
		})

		/**************交易状态****************/

		$(".trade li").each(function() {
			$(this).on("click", function() {
				/********点击不同状态，显示不同的东西***********/
				$(".jiaoyi i").css("transform", "rotate(0deg)");
				$(".trade").css("display", "none");
				$(".jiaoyi").css({
					"color": "#99999A",
					"background": "#f8f8f8"
				})
				$(".jiaoyi span").css("color", "#99999A");
				$(".jiaoyi i").css("color", "#99999A");

			})
		})

	})
	$(".jiaoyi").on("mouseleave", function() {
		$(".jiaoyi i").css("transform", "rotate(0deg)");
		$(".trade").css("display", "none");
		$(".jiaoyi").css({
			"color": "#99999A",
			"background": "#f8f8f8"
		})
		$(".jiaoyi span").css("color", "#99999A");
		$(".jiaoyi i").css("color", "#99999A");
	})

	/*************动态改变状态的距离 E*******************/
	/*************评价弹出层 S*******************/

	$(".evaluate").on("click", function() {
		$(".order8_mask2").fadeIn();
	});
	$("#o8_mask2_d").on("click", function() {
			$(".order8_mask2").fadeOut();
			clear_photo();
		})
		/************评价弹出层 E*******************/
		//*********评价系统 S*****************
	$("#xingxing1 li:nth-child(1)").on("mouseover", function() {
		dele_class($(".stytle1"), "bg2", "0");
	})
	$("#xingxing1 li:nth-child(2)").on("mouseover", function() {
		dele_class($(".stytle1"), "bg2", "0");
	})
	$("#xingxing1 li:nth-child(3)").on("mouseover", function() {
		dele_class($(".stytle1"), "bg4", "2");
	})
	$("#xingxing1 li:nth-child(4)").on("mouseover", function() {
		dele_class($(".stytle1"), "bg4", "2");
	})
	$("#xingxing1 li:nth-child(5)").on("mouseover", function() {
		dele_class($(".stytle1"), "bg6", "4");
	})
	$("#xingxing1 li:nth-child(6)").on("mouseover", function() {
		dele_class($(".stytle1"), "bg6", "4");
	})
	$("#xingxing1 li:nth-child(7)").on("mouseover", function() {
		dele_class($(".stytle1"), "bg8", "6");
	})
	$("#xingxing1 li:nth-child(8)").on("mouseover", function() {
		dele_class($(".stytle1"), "bg8", "6");
	})
	$("#xingxing1 li:nth-child(9)").on("mouseover", function() {
		dele_class($(".stytle1"), "bg10", "8");
	})
	$("#xingxing1 li:nth-child(10)").on("mouseover", function() {
		dele_class($(".stytle1"), "bg10", "8");
	})
	$("#xingxing2 li:nth-child(1)").on("mouseover", function() {
		dele_class($(".stytle2"), "bg2", "0");
	})
	$("#xingxing2 li:nth-child(2)").on("mouseover", function() {
		dele_class($(".stytle2"), "bg2", "0");
	})
	$("#xingxing2 li:nth-child(3)").on("mouseover", function() {
		dele_class($(".stytle2"), "bg4", "2");
	})
	$("#xingxing2 li:nth-child(4)").on("mouseover", function() {
		dele_class($(".stytle2"), "bg4", "2");
	})
	$("#xingxing2 li:nth-child(5)").on("mouseover", function() {
		dele_class($(".stytle2"), "bg6", "4");
	})
	$("#xingxing2 li:nth-child(6)").on("mouseover", function() {
		dele_class($(".stytle2"), "bg6", "4");
	})
	$("#xingxing2 li:nth-child(7)").on("mouseover", function() {
		dele_class($(".stytle2"), "bg8", "6");
	})
	$("#xingxing2 li:nth-child(8)").on("mouseover", function() {
		dele_class($(".stytle2"), "bg8", "6");
	})
	$("#xingxing2 li:nth-child(9)").on("mouseover", function() {
		dele_class($(".stytle2"), "bg10", "8");
	})
	$("#xingxing2 li:nth-child(10)").on("mouseover", function() {
		dele_class($(".stytle2"), "bg10", "8");
	})
	$("#xingxing3 li:nth-child(1)").on("mouseover", function() {
		dele_class($(".stytle3"), "bg2", "0");
	})
	$("#xingxing3 li:nth-child(2)").on("mouseover", function() {
		dele_class($(".stytle3"), "bg2", "0");
	})
	$("#xingxing3 li:nth-child(3)").on("mouseover", function() {
		dele_class($(".stytle3"), "bg4", "2");
	})
	$("#xingxing3 li:nth-child(4)").on("mouseover", function() {
		dele_class($(".stytle3"), "bg4", "2");
	})
	$("#xingxing3 li:nth-child(5)").on("mouseover", function() {
		dele_class($(".stytle3"), "bg6", "4");
	})
	$("#xingxing3 li:nth-child(6)").on("mouseover", function() {
		dele_class($(".stytle3"), "bg6", "4");
	})
	$("#xingxing3 li:nth-child(7)").on("mouseover", function() {
		dele_class($(".stytle3"), "bg8", "6");
	})
	$("#xingxing3 li:nth-child(8)").on("mouseover", function() {
		dele_class($(".stytle3"), "bg8", "6");
	})
	$("#xingxing3 li:nth-child(9)").on("mouseover", function() {
		dele_class($(".stytle3"), "bg10", "8");
	})
	$("#xingxing3 li:nth-child(10)").on("mouseover", function() {
		dele_class($(".stytle3"), "bg10", "8");
	})
	var pinjia_res = ["一颗星", "一颗半星", "两颗星", "两颗半星", "三颗星", "三颗半星", "四颗星", "四颗半星", "五颗星"];

	function dele_class(obj, stage, content) {
		if(obj.hasClass("stytle1")) {
			var style_color = "stytle1 " + stage;
			$(".res1").html(pinjia_res[content]);
		} else if(obj.hasClass("stytle2")) {
			var style_color = "stytle2 " + stage;
			$(".res2").html(pinjia_res[content]);
		} else if(obj.hasClass("stytle3")) {
			var style_color = "stytle3 " + stage;
			$(".res3").html(pinjia_res[content]);
		}
		obj.attr("class", style_color);
	}
	//*********评价系统 E*****************
	/**************************计算字数 S**********************/
	var textarea = $("textarea"),
		zishu = $(".o8_num span"),
		area_val = "";
	textarea.on("keyup", function() {
		var textarea_val = textarea.val();
		if(textarea[0].value == '') {
			zishu.text("0");
		} else {
			var reg = /[\u4e00-\u9fa5\w]/g;
			if(textarea_val.match(reg).length > 200) {
				textarea_val = area_val;
			} else {
				area_val = textarea_val;
				zishu.text(area_val.length);
			}
		}
	});
	/**************************计算字数 E**********************/
	/**************************上传图片 S**********************/
	$("input[type=file]").on("change", function() {
			for(var i = 1; i <= this.files.length; i++) {
				if($(".o8_img_up").length + i > 5) {
					$("#shanchuchenggong").text("上传图片已超过五张");
					$("#shanchu2").fadeIn();
					break;
				} else {
					$(".o8_photo_num1").html($(".o8_img_up").length + i);
					$(".o8_photo_num2").html(5 - ($(".o8_img_up").length + i));
				}
				var file = this.files[i - 1];
				if(!/image\/\w+/.test(file.type)) {
					$("#shanchuchenggong").text("请传入有效图片");
					$("#shanchu2").fadeIn();
				} else if(file.fileSize >= 5242880) {
					$("#shanchuchenggong").text("上传图片要小于5M");
					$("#shanchu2").fadeIn();
				} else {
					if($(".o8_img_up").length < 5) {
						if(window.FileReader) {
							var fr = new FileReader();
							fr.onloadend = function(e) {
								var imgs = "<span class='o8_img_up'><div class='o8_mask_dele'>删除</div><img src='" + e.target.result + "'/></span>";
								$(imgs).insertAfter($(".o8_img_click"));
								$(".o8_mask_dele").bind("click", function() {
									$(this).parent().remove();
									$(".o8_photo_num1").html($(".o8_img_up").length);
									$(".o8_photo_num2").html(5 - $(".o8_img_up").length);
								})
							};
							fr.readAsDataURL(file);
						}
					} else {
						$("#shanchuchenggong").text("上传图片已超过五张");
						$("#shanchu2").fadeIn();
					}
				}
			}
		})
		/**************************上传图片 E**********************/
		/**************************确认收货跳转 S**********************/
	$(".o5_pinjia").on("click", function() {
			$(".order8_mask2").fadeOut();
			clear_photo();
			window.location.href = "../my_order/wodedingdan.html";
		})
		/**************************确认收货跳转 E**********************/

	/**************************订单总页面里的订单样式改变 S**********************/
	$(".o8_select").on("click", function() {
			$(".order_o8_mid ul li").removeClass("o8_active");
			$(".order_o8_mid ul li span").removeClass("o8_opacity");
			$(this).addClass("o8_active");
			$(this).next().children().addClass("o8_opacity");
			var now = $(this).attr("id");
			$(".order_o8_bot_con1").removeClass("o8_margin");
			switch(now % 5) {
				case 1:
					$(".order_o8_bot_con1").addClass("o8_margin");
					$(".order_o8_bot_con1").eq(0).removeClass("o8_margin");
					$(".order_o8_bot_con1").css("display", "block");
					break;
				case 2:
					$(".order_o8_bot_con1").css("display", "none");
					$("#o8_1").css("display", "block");
					break;
				case 3:
					$(".order_o8_bot_con1").css("display", "none");
					$("#o8_2").css("display", "block");
					break;
				case 4:
					$(".order_o8_bot_con1").css("display", "none");
					$("#o8_3").css("display", "block");
					break;
				default:
					$(".order_o8_bot_con1").css("display", "none");
					$("#o8_4").css("display", "block");
					break;
			}
		})
		/**************************订单总页面里的订单样式改变 S**********************/

	/**************************订单总页面 S**********************/
	$("#o8_mask2_d").on("click", function() {
		$(".order8_mask2").fadeOut();
		clear_photo();
	})
	$(".o8_evaluate").on("click", function() {
		$(".order8_mask2").fadeIn();
	})
	$(".o8_conf").on("click", function() {
		window.open("../exports/gou_wlc.html");
	})
	$(".o8_red1").on("click", function() {
		window.open("../my_order/wuliuxinxi.html");
	})
	var o8_clearOrder = $(".o8_clearOrder"),
		o8_confOrder = $(".o8_confOrder"),
		shanchu2 = $("#shanchu2"),
		shanchu1 = $("#shanchu1"),
		querenshanchu1 = $("#querenshanchu1"),
		querenshanchu2 = $("#querenshanchu2"),
		querenshanchu3 = $("#querenshanchu3"),
		o5_ok = $("#wodzz2_mask_ok"),
		o5_dele = $("#o5_dele"),
		o5_no = $("#wodzz2_mask_no"),
		shanchuchenggong = $("#shanchuchenggong"),
		chacha = $("#chacha");
	o8_clearOrder.on("click", function() {
		querenshanchu2.css("display", "none");
		querenshanchu3.css("display", "none");
		querenshanchu1.css("display", "block");
		shanchu1.fadeIn();
		o8_change(1);
	});
	o8_confOrder.on("click", function() {
		querenshanchu1.css("display", "none");
		querenshanchu3.css("display", "none");
		querenshanchu2.css("display", "block");
		shanchu1.fadeIn();
		o8_change(2);
	});
	$(".o8_delete img").on("click", function() {
		querenshanchu1.css("display", "none");
		querenshanchu2.css("display", "none");
		querenshanchu3.css("display", "block");
		shanchu1.fadeIn();
		o8_change(3);
	});
	o5_dele.on("click", function() {
		shanchu1.css("display", "none");
	});
	o5_ok.on("click", function() {
		shanchu1.fadeOut();
		shanchuchenggong.text(o8_str1);
		shanchu2.fadeIn();
	});
	o5_no.on("click", function() {
		shanchu1.fadeOut();
		shanchuchenggong.text(o8_str2);
		shanchu2.fadeIn();
	});
	chacha.on("click", function() {
			shanchu2.fadeOut();
		})
		/**************************订单总页面 S**********************/
		/*********评分系统关闭 S*****************/
	function clear_photo() {
		setTimeout(function() {
			$("span").remove(".o8_img_up");
			var style_color1 = "stytle1 bg0";
			var style_color2 = "stytle2 bg0";
			var style_color3 = "stytle3 bg0";
			$(".res1").html("");
			$(".res2").html("");
			$(".res3").html("");
			$(".stytle1").attr("class", style_color1);
			$(".stytle2").attr("class", style_color2);
			$(".stytle3").attr("class", style_color3);
			$(".order8_mask2 textarea").val("");
			$(".order8_mask2 .o8_num span").html("0");
		}, 500)
	}
	/*********评分系统关闭 S*****************/

	$(".jiantou").each(function() {
		$(this).on("mouseenter", function() {
			$(this).parent().find(".dialog").css({
				"display": "block",
				"z-index": "99",
				"left": "-32px",
				"bottom": "58px",
				"text-align": "center"
			});
			$(this).css("background", "#f8f8f8");
		})
		$(this).on("mouseleave", function() {
			$(this).parent().find(".dialog").css({
				"display": "none",
				"z-index": "99",
				"left": "-32px",
				"bottom": "58px",
				"text-align": "center"
			});
			$(this).css("background", "none");
		})
	})
	
	/*********数量弹窗 S*****************/
	$(".order_inf_big_content_detail_span3 .jiantou").each(function() {
		$(this).on("mouseenter", function() {
			$(this).parent().find(".dialog").css({
				"display": "block",
				"z-index": "99",
				"left": "-47px",
				"bottom": "27px",
				"text-align": "center"
			});
			$(this).css("background", "#f8f8f8");
		})
		$(this).on("mouseleave", function() {
			$(this).parent().find(".dialog").css({
				"display": "none",
				"z-index": "99",
				"left": "-47px",
				"bottom": "27px",
				"text-align": "center"
			});
			$(this).css("background", "none");
		})
	})
	/*********数量弹窗 E*****************/

	/***********************已拆分部分*********************/
	$(".gantan").on("mouseenter", function() {
		$(this).parent().parent().find(".dialog").css({
			"display": "block",
			"bottom": "37px",
			"z-index": "100",
			"left": "380px",
			"width": "200px"
		})
	})
	$(".gantan").on("mouseleave", function() {
		$(this).parent().parent().find(".dialog").css({
			"display": "none",
			"bottom": "40px",
			"z-index": "100",
			"left": "380px"
		})
	})

	/*************动态改变状态的距离*******************/
	var o1_height = (59 - $(".order_big1").length);
	$(".order_order1").css("bottom", "" + o1_height + "%")
	var o2_height = (58 - $(".order_big2").length);
	$(".order_order2").css("bottom", "" + o2_height + "%")
	var o3_height = (55 - $(".order_big3").length);
	$(".order_order3").css("bottom", "" + o3_height + "%")
	var o4_height = (55 - $(".order_big4").length);
	$(".order_order4").css("bottom", "" + o4_height + "%")
	var o5_height = (54 - $(".order_big5").length);
	$(".order_order5").css("bottom", "" + o5_height + "%")
	var o6_height = (55 - $(".order_big6").length);
	$(".order_order6").css("bottom", "" + o6_height + "%")

})();